## ISBN check digit

'''
The function isbn(x) yields the check digit
of a 9-digit list x. 

We have to use (j+1)*x[j], an not j*x[j], 
because x[j] is the (j+1)th element of the list.

The examples correspond to the two books referred to
in the text.
'''
from PyM import *

def isbn(x):
    r = (sum([(j+1)*x[j] for j in range(len(x))])) % 11
    if r==10: return 'X'
    return r


show(isbn([3,5,4,0,0,0,3,9,5]))

show(isbn([0,3,8,7,9,6,6,1,7]))